<?php
    class StudentDormitoryListBLL{
        //导出学生宿舍信息到excel
        public function exportExcel($instructorID,$excelInfo){
            $PHPExcelOperation=new PHPExcelOperation();
            $studentList=array();
            $result=$this->getStudentInfo($excelInfo->grade,$excelInfo->major,$excelInfo->class,$excelInfo->search);
            foreach($result as $student){
                $student['gender']=$student['gender']==1?'女':'男';
                $studentList[]=$student;
            }
            $fileheader= array('学号', '姓名', '性别', '年级','专业','班级','公寓','宿舍'); 
            $PHPExcelOperation->exportExcel($studentList, $instructorID.'excel', $fileheader, 'Sheet1');
        }
        //获取学生信息
        public function getStudentInfo($grade,$major,$class,$search){
            $StudentDormitoryListDAL=new StudentDormitoryListDAL();
            $result=$StudentDormitoryListDAL->getStudentInfo($grade,$major,$class,$search);

            return $result;
        }
        //获取学生列表
        public function getStudentList($instructorID,$grade,$major,$class,$search,$page,$pageSize){
            $sde=new StudentDormitoryExchangeDAL();
            $result=$sde->getStudentList($grade,$major,$class,$search,$page,$pageSize);
            $result['page']=$this->getStudentListPage($result['count'],$pageSize);
            return $result;
        }

        //获取学生列表页数
        public function getStudentListPage($count,$pageSize){
            $pageMax=0;
            if($count>$pageSize){
                if($count%$pageSize===0){
                    $pageMax=(int)($count/$pageSize);
                }else{
                    $pageMax=(int)($count/$pageSize)+1;
                }
            }
            
            return $pageMax;
        }
        //获取辅导员分配的宿舍列表
        public function getInstructorAllocateList($instructorID){
            $PublicDataDAL=new PublicDataDAL();
            $result=$PublicDataDAL->getInstructorAllocateList($instructorID);
            return $result;
        }
    }
?>